package cn.tedu.boyou.acticle.service.impl;

import cn.tedu.boyou.acticle.domain.StrategyTheme;
import cn.tedu.boyou.acticle.mapper.StrategyThemeMapper;
import cn.tedu.boyou.acticle.service.IStrategyThemeService;
import cn.tedu.boyou.common.query.StrategyThemeQuery;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class StrategyThemeServiceImpl implements IStrategyThemeService {
    @Autowired
    private StrategyThemeMapper strategyThemeMapper;

    public PageInfo query(StrategyThemeQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<StrategyTheme> regions = strategyThemeMapper.selectForList(qo);
        return new PageInfo(regions);
    }

    public void saveOrUpdate(StrategyTheme strategyTheme) {
        if(strategyTheme.getId() != null){
            strategyThemeMapper.updateByPrimaryKey(strategyTheme);
        }else{
            strategyThemeMapper.insert(strategyTheme);
        }

    }

    public void delete(Long id) {
        strategyThemeMapper.deleteByPrimaryKey(id);
    }

    public List<StrategyTheme> listAll() {
        return strategyThemeMapper.selectAll();
    }
}
